<html>
<head><meta charset="utf-8"><title>rust-analyser perf · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/rust-analyser.20perf.html">rust-analyser perf</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="218950480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/rust-analyser%20perf/near/218950480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/rust-analyser.20perf.html#218950480">(Dec 05 2020 at 19:54)</a>:</h4>
<p>Is there a place where I can find out why the AST is represented as a linked list vs something like a Vector of statements/expressions?</p>



<a name="218950581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/rust-analyser%20perf/near/218950581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/rust-analyser.20perf.html#218950581">(Dec 05 2020 at 19:57)</a>:</h4>
<p>Maybe ask <span class="user-mention silent" data-user-id="133169">matklad</span>?</p>



<a name="218950656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/rust-analyser%20perf/near/218950656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/rust-analyser.20perf.html#218950656">(Dec 05 2020 at 19:58)</a>:</h4>
<p>Also wondering why we need an elided lifetime here? <a href="https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/parser/src/lib.rs#L109">https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/parser/src/lib.rs#L109</a></p>
<p>It's insignificant if it's not needed, but it seems I am missing something about the compiler here</p>



<a name="218950838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/rust-analyser%20perf/near/218950838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/rust-analyser.20perf.html#218950838">(Dec 05 2020 at 20:02)</a>:</h4>
<p>it compiles without the explicit lifetime, so I guess the answer is "we don't"</p>



<a name="218950851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/rust-analyser%20perf/near/218950851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/rust-analyser.20perf.html#218950851">(Dec 05 2020 at 20:02)</a>:</h4>
<p>what do you mean by "the AST is represented as a linked list"?</p>



<a name="218950898"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/rust-analyser%20perf/near/218950898" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/rust-analyser.20perf.html#218950898">(Dec 05 2020 at 20:03)</a>:</h4>
<p>there are various things that one could call AST in RA, but I can't think of one that's represented as a linked list right now</p>



<a name="218950902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/rust-analyser%20perf/near/218950902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/rust-analyser.20perf.html#218950902">(Dec 05 2020 at 20:03)</a>:</h4>
<p><span class="user-mention silent" data-user-id="129457">Florian Diebold</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/rust-analyser.20perf/near/218950838">said</a>:</p>
<blockquote>
<p>it compiles without the explicit lifetime, so I guess the answer is "we don't"</p>
</blockquote>
<p>Yep, I was not sure if I missing something</p>



<a name="218950992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/rust-analyser%20perf/near/218950992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/rust-analyser.20perf.html#218950992">(Dec 05 2020 at 20:05)</a>:</h4>
<p><span class="user-mention silent" data-user-id="129457">Florian Diebold</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/rust-analyser.20perf/near/218950851">said</a>:</p>
<blockquote>
<p>what do you mean by "the AST is represented as a linked list"?</p>
</blockquote>
<p>Oh I might have misunderstood the code then. I was referring to the SyntaxNode, if that makes it a bit clearer?</p>



<a name="218951038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/rust-analyser%20perf/near/218951038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/rust-analyser.20perf.html#218951038">(Dec 05 2020 at 20:06)</a>:</h4>
<p>Where I believe each node linked to a parent node, except the root</p>



<a name="218951082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/rust-analyser%20perf/near/218951082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/rust-analyser.20perf.html#218951082">(Dec 05 2020 at 20:08)</a>:</h4>
<p>yeah, <code>SyntaxNode</code>s are kind of a cursor over the underlying immutable syntax tree. They are basically for navigation through the tree, so the link to the parent node is needed. Siblings aren't represented as a linked list though. There's a big document <a href="https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/dev/syntax.md">here</a> that explains the design of the syntax tree</p>



<a name="218951215"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/rust-analyser%20perf/near/218951215" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/rust-analyser.20perf.html#218951215">(Dec 05 2020 at 20:10)</a>:</h4>
<p><span class="user-mention silent" data-user-id="129457">Florian Diebold</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/rust-analyser.20perf/near/218951082">said</a>:</p>
<blockquote>
<p>yeah, <code>SyntaxNode</code>s are kind of a cursor over the underlying immutable syntax tree. They are basically for navigation through the tree, so the link to the parent node is needed. Siblings aren't represented as a linked list though. There's a big document <a href="https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/dev/syntax.md">here</a> that explains the design of the syntax tree</p>
</blockquote>
<p>Oh I see my error. This document is very helpful, thank you very much</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>